//
// 作者：AKA_GGbond
// 时间：2025/7/17
// 邮箱：evain_wl@163.com
//

#ifndef ESMU_W_HELLOBUTTON_H
#define ESMU_W_HELLOBUTTON_H

#include <QPushButton>

class QPropertyAnimation;

class W_HelloButton : public QPushButton
{
    Q_OBJECT
    Q_PROPERTY(QString center_text READ center_text WRITE setCenter_text FINAL)
    Q_PROPERTY(int radius READ radius WRITE setRadius FINAL)
    Q_PROPERTY(int opacity READ opacity WRITE setOpacity FINAL)

public:
    explicit W_HelloButton(QWidget *parent = nullptr);
    ~W_HelloButton();

    enum AnimationState {
        ANIMATION_STATE_EXECUTING,
        ANIMATION_STATE_RESET
    };

protected:
    void paintEvent(QPaintEvent* event);
    void mousePressEvent(QMouseEvent* event);
    void mouseReleaseEvent(QMouseEvent* event);


public:
    QString center_text() const;
    void setCenter_text(const QString &newCenter_text);

    int radius() const;
    void setRadius(int newRadius);

    int opacity() const;
    void setOpacity(int newOpacity);

    void animation_status(bool status);

private:
    void draw_disappearing_circle();
    void draw_border();
    void draw_text();
    void reset_animation();
    void execute_animation();

signals:
    void page_changed(AnimationState status);

private:
    QPoint mouse_coordinates;
    QPropertyAnimation* animation1{nullptr};
    QPropertyAnimation* animation3{nullptr};

    QString m_center_text;
    int m_radius = 0;
    int m_opacity = 255;
    bool status = true;
};


#endif //ESMU_W_HELLOBUTTON_H
